package com.gitee.proxy.server;

import com.gitee.proxy.common.CryptoDESUtil;
import com.gitee.proxy.common.SocketRunnable;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

@Slf4j
public class SocketServer {
    public static void main(String[] args) {
        int port = 9999;
        java.security.Security.setProperty("networkaddress.cache.ttl", "86400");
        log.info("config =>> port=" + port);
        try (ServerSocket serverSocket = new ServerSocket(port)) {
            Socket socket = null;
            while ((socket = serverSocket.accept()) != null) {
                new Thread(new SocketRunnable(socket) {
                    @Override
                    public byte[] source2proxy(byte[] bytes) {
                        return bytes;
                    }

                    @Override
                    public byte[] proxy2source(byte[] bytes) {
                        return bytes;
                    }
                }).start();
            }
        } catch (IOException e) {
            log.error("", e);
        }
    }
}
